﻿using System;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;
using Hopscotch.Presentation.Common;
using Hopscotch.Presentation.Common.Utils;
using Hopscotch.Presentation.Controls.DataProviders;
using Hopscotch.Presentation.TradeModule.Services;
using Hopscotch.Presentation.TradeModule.Views;
using Hopscotch.Domain.Enquiry;

namespace Hopscotch.Presentation.TradeModule
{
    public class Module : IModule
    {
        private readonly IAppController shellController;

        public Module(IAppController shellController)
        {
            this.shellController = shellController;
        }

        public void Initialize()
        {
            var container = ServiceLocator.Current.GetInstance<IUnityContainer>();

            var uri = new Uri(IconPaths.Wallet16);
            shellController.RegisterTool("Trade", typeof(TradeView), uri);
            shellController.RegisterTool("Trade Blotter", typeof(TradeBlotterView), uri);

            // Register other view objects with DI Container (Unity)
            container.RegisterType<Object, TradeView>(typeof(TradeView).Name);

            //Register data providers used by child controls
            container.RegisterType<IPriceControlDataProvider, PriceControlDataProvider>();
            container.RegisterType<IInstrumentDataProvider, InstrumentDataProvider>();

        }

    }
}
